﻿namespace Z2.Editor
{
	using System;
	using System.Windows.Forms;

	public partial class MapProperties : Form
	{

		private World m_world;

		public MapProperties(World world)
			: this()
		{
			this.m_world = world;
		}

		public MapProperties()
		{
			this.InitializeComponent();
			this.cbTheme.SelectedIndex = 0;
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			if (this.m_world != null)
			{
				this.tbAuthor.Text = this.m_world.Author;
				this.tbName.Text = this.m_world.Name;
			}
			else
			{
				this.tbAuthor.Text = Environment.UserName;
			}
		}

		protected override void OnShown(EventArgs e)
		{
			base.OnShown(e);
			this.tbName.Focus();
		}

		public World World
		{
			get
			{
				return this.m_world;
			}
		}

		private void btOK_Click(object sender, EventArgs e)
		{
			if (this.m_world == null)
			{
				this.m_world = new World();
			}
			
			this.m_world.Author = this.tbAuthor.Text.Trim();
			this.m_world.Name = this.tbName.Text.Trim();

			this.DialogResult = DialogResult.OK;
		}

	}
}
